﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WarehouseManager.DataAccess
{
    class LayMa
    {
        
        public LayMa() { 
        }
        public string NextID(String lastID)
        {
            if (lastID == "") return "PN0001";
            string s = "";
            int dem = 0;
            for (int i = (lastID.Length - 1); i > 2; i--)
            {
                int temp = (int)lastID[i] - 48;
                if (temp < 9)
                {
                    dem++;
                    temp = (temp + 48 + 1);
                    s = (char)temp + s;
                    break;
                }
                if (temp == 9)
                {
                    dem++;
                    s = '0' + s;
                }

            }
            for (int t = lastID.Length - dem - 1; t >= 0; t--)
            {
                s = lastID[t] + s;
            }
            return s;
        }
        public string NextIDPX(String lastID)
        {
            if (lastID == "") return "PX0001";
            string s = "";
            int dem = 0;
            for (int i = (lastID.Length - 1); i > 2; i--)
            {
                int temp = (int)lastID[i] - 48;
                if (temp < 9)
                {
                    dem++;
                    temp = (temp + 48 + 1);
                    s = (char)temp + s;
                    break;
                }
                if (temp == 9)
                {
                    dem++;
                    s = '0' + s;
                }

            }
            for (int t = lastID.Length - dem - 1; t >= 0; t--)
            {
                s = lastID[t] + s;
            }
            return s;
        }
    }
}
